const service = require('../service/user.service')
const fs = require('fs')
class UserController {
  async create(ctx,next){
    const user = ctx.request.body
    ctx.body = await service.create(user)

  }

  async avatarInfo(ctx,next){
    const {userId} = ctx.params
    const avatarInfo = await service.getAvatarInfo(userId)
    ctx.response.set('content-type',avatarInfo.mimetype)
    ctx.body = fs.createReadStream(`uploads/avatar/${avatarInfo.filename}`)
  }
}

module.exports = new UserController();